/**
 *
 */
package com.zhuoyue.elmt.web;

import com.eit.eitsite.common.config.Global;
import com.eit.eitsite.common.persistence.Page;
import com.eit.eitsite.common.utils.StringUtils;
import com.eit.eitsite.common.web.BaseController;
import com.eit.eitsite.modules.sys.utils.UserUtils;
import com.zhuoyue.elmt.data.ResultData;
import com.zhuoyue.elmt.entity.DeviceParameters;
import com.zhuoyue.elmt.entity.Ecemp;
import com.zhuoyue.elmt.service.DeviceParametersService;
import com.zhuoyue.elmt.service.FailureReportService;
import com.zhuoyue.elmt.service.MaintenanceRecordSzService;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
import net.sf.json.util.CycleDetectionStrategy;
import net.sf.json.util.PropertyFilter;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.crypto.Data;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 电梯查询Controller
 *
 * @author chenhao
 * @version 2016-06-12
 */
@Controller
@RequestMapping(value = "${adminPath}/elmt/analysis")
public class AnalysisController extends BaseController {

    @Autowired
    private DeviceParametersService deviceParametersService;

    @ModelAttribute
    public DeviceParameters get(@RequestParam(required = false) String id) {
        DeviceParameters entity = null;
        if (StringUtils.isNotBlank(id)) {
            entity = deviceParametersService.get(id);
        }
        if (entity == null) {
            entity = new DeviceParameters();
        }
        return entity;
    }

    //*********************************************微信公众平台********************************************************//
    //产品体验 -> 电梯维保
    @RequestMapping(value = {"elevatorMaintenance", ""})
    public String elevatorMaintenance(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/product/elevatorMaintenance";
    }

    //产品体验 -> 智能急救
    @RequestMapping(value = {"intelligentFirstAid", ""})
    public String intelligentFirstAid(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/product/intelligentFirstAid";
    }

    //产品体验 -> 急救收费
    @RequestMapping(value = {"firstAidFee", ""})
    public String firstAidFee(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/product/firstAidFee";
    }

    //产品体验 -> 移动就医
    @RequestMapping(value = {"medicalAttention", ""})
    public String medicalAttention(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/product/medicalAttention";
    }

    //NEWS! -> 企业宣传册
    @RequestMapping(value = {"businessBook", ""})
    public String businessBook(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/news/businessBook";
    }

    //NEWS! -> 产品宣传册
    @RequestMapping(value = {"productsPictorial", ""})
    public String productsPictorial(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/news/productsPictorial";
    }

    //NEWS! -> 头条
    @RequestMapping(value = {"headlineNews", ""})
    public String headlineNews(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/news/headlineNews";
    }

    //NEWS! -> 新闻中心
    @RequestMapping(value = {"newsInfo", ""})
    public String newsInfo(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/news/newsInfo";
    }

    //了解卓越 -> 企业介绍
    @RequestMapping(value = {"companyInfo", ""})
    public String companyInfo(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/about/companyInfo";
    }

    //了解卓越 -> 产品案例
    @RequestMapping(value = {"productCase", ""})
    public String productCase(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/about/productCase";
    }

    //了解卓越 -> 招贤纳士
    @RequestMapping(value = {"recruitmentInfo", ""})
    public String recruitmentInfo(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/about/recruitmentInfo";
    }

    //了解卓越 -> 意见反馈
    @RequestMapping(value = {"feedback", ""})
    public String feedback(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/weixin/about/feedback";
    }
    //*********************************************微信公众平台********************************************************//

    //进入首页
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"index", ""})
    public String index(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/analysis/index";
    }

    /**
     * 电梯运行状态情况统计
     *
     * @param str1
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/statByDeviceStatus/{str1}")
    public String statByDeviceStatus(@PathVariable String str1, HttpServletRequest request, HttpServletResponse response, Model model) {
        System.out.println("电梯运行状态情况统计 ===========================================>>>>>>>>>>>>>>");
        HashMap param = new HashMap();
        param.put("dbName", Global.getConfig("jdbc.type"));
        param.put("deptCode", UserUtils.getUser().getCompany().getCode());
        HashMap result = deviceParametersService.statByDeviceStatus(param);
        return super.renderString(response, result);
    }

    /**
     * 查询单条设备信息
     *
     * @param str1
     * @param response
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/getDeviceParameter/{str1}")
    public String getDeviceParameter(@PathVariable String str1, HttpServletResponse response) {
        ResultData<List<DeviceParameters>> resultData = new ResultData();
        List<DeviceParameters> list = new ArrayList();
        try {
            System.out.println("查询单条设备信息 ===========================================>>>>>>>>>>>>>>");
            DeviceParameters record = deviceParametersService.get(str1);
            if (record != null) {
                resultData.setCode("SUCC");
                resultData.setMessage("SUCCESS");
            } else {
                resultData.setCode("FAIL");
                resultData.setMessage("没有查询到符合条件的设备信息！");
            }
            list.add(record);
            resultData.setList(list);
        } catch (Exception e) {
            resultData.setCode("FAIL");
            resultData.setMessage("设备信息查询出现异常！");
            e.printStackTrace();
        }
        return super.renderString(response, resultData);
    }

    /**
     * 查询多条设备信息
     *
     * @param deviceParameters
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/findDeviceParameter")
    public String findDeviceParameter(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response) {
        ResultData<List<DeviceParameters>> resultData = new ResultData();
        try {
            System.out.println("查询多条设备信息 ===========================================>>>>>>>>>>>>>>");
            Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
            if (null != page) {
                resultData.setList(page.getList());
            }
            resultData.setCode("SUCC");
            resultData.setMessage("");
        } catch (Exception e) {
            resultData.setCode("FAIL");
            resultData.setMessage("设备信息查询出现异常！");
            e.printStackTrace();
        }
        return super.renderString(response, resultData);
    }

    @RequiresPermissions("elmt:wbDeviceParameters:view")
    @RequestMapping(value = {"list", ""})
    public String list(DeviceParameters deviceParameters, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DeviceParameters> page = deviceParametersService.findPage(new Page<DeviceParameters>(request, response), deviceParameters);
        model.addAttribute("page", page);
        return "zhuoyue/elmt/wbDeviceParametersList";
    }


    //电梯无有效维保合同情况统计
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statByNoMaintenanceContract"})
    public String statByNoMaintenanceContract(String useUnitCode, String useUnitName, String unitAddress, HttpServletRequest request, HttpServletResponse response, Model model) {
        HashMap statParameters = getHashMap(useUnitCode, useUnitName, unitAddress);
        List<HashMap> list = deviceParametersService.statByNoMaintenanceContract(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statByNoMaintenanceContract";
    }

    //电梯无指定维保人员情况统计
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statByNoMaintenanceStaff"})
    public String statByNoMaintenanceStaff(String maintenanceUnitCode, String maintenanceUnitName, String unitAddress, HttpServletRequest request, HttpServletResponse response, Model model) {
        HashMap statParameters = getHashMap(maintenanceUnitCode, maintenanceUnitName, unitAddress);
        List<HashMap> list = deviceParametersService.statByNoMaintenanceStaff(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statByNoMaintenanceStaff";
    }

	//电梯无有效维保合同情况统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenance"})
	@ResponseBody
	public String  statByNoMaintenance(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
        Integer dtzs = deviceParametersService.statByNoMaintenance(zzjgdm);
		Integer wwbsl = deviceParametersService.statByNoMaintenance2(zzjgdm);
		Map params =  new HashMap();

		params.put("dtzs", dtzs);
		params.put("wwbsl", wwbsl);
		JSONArray array = JSONArray.fromObject(params);
		response.getWriter().print(array.toString());
		response.getWriter().flush();
		response.getWriter().close();
		return null;
	}

	//电梯无有效维保合同情况统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenanceMan"})
	@ResponseBody
	public String  statByNoMaintenanceMan(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
		Integer dtzs = deviceParametersService.statByNoMaintenance(zzjgdm);
		Integer ywbrysl = deviceParametersService.statByNoMaintenance3(zzjgdm);
		Map params =  new HashMap();
		params.put("dtzs", dtzs);
		params.put("ywbrysl", ywbrysl);
		JSONArray array = JSONArray.fromObject(params);
		response.getWriter().print(array.toString());
		response.getWriter().flush();
		response.getWriter().close();
		return null;
	}

	//电梯维保存在安全隐患情况统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenanceMan4"})
	@ResponseBody
	public List  statByNoMaintenanceMan4(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
		List<Ecemp> list = deviceParametersService.statByNoMaintenance4(zzjgdm);

		return list;
	}
	//电梯故障情况统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenanceMan5"})
	@ResponseBody
	public List  statByNoMaintenanceMan5(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
		List<Ecemp> list = deviceParametersService.statByNoMaintenance5(zzjgdm);

		return list;
	}
	//电梯困人情况统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenanceMan6"})
	@ResponseBody
	public List  statByNoMaintenanceMan6(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
		List<Ecemp> list = deviceParametersService.statByNoMaintenance6(zzjgdm);

		return list;
	}
	//电梯维保逾期统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenanceMan7"})
	@ResponseBody
	public String  statByNoMaintenanceMan7(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
		Ecemp obj = deviceParametersService.statByNoMaintenance7(zzjgdm);
		Map params =  new HashMap();
		params.put("bysl", obj.getBysl());
		params.put("jdsl", obj.getJdsl());
		params.put("bnsl", obj.getBnsl());
		params.put("qnsl", obj.getQnsl());
		params.put("qnzs", obj.getQnzs());
		JSONArray array = JSONArray.fromObject(params);
		response.getWriter().print(array.toString());
		response.getWriter().flush();
		response.getWriter().close();
		return null;
	}
	//电梯运行状态统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenanceMan8"})
	@ResponseBody
	public String  statByNoMaintenanceMan8(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
		Ecemp obj = deviceParametersService.statByNoMaintenance8(zzjgdm);
		Map params =  new HashMap();
		params.put("tysl", obj.getTysl());
		params.put("zysl", obj.getZysl());
		params.put("zjsl", obj.getZjsl());
		params.put("bfsl", obj.getBfsl());
		params.put("dclsl", obj.getDclsl());
		params.put("zxsl", obj.getZxsl());
		JSONArray array = JSONArray.fromObject(params);
		response.getWriter().print(array.toString());
		response.getWriter().flush();
		response.getWriter().close();
		return null;
	}

	//电梯维保不合格率统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenanceMan9"})
	@ResponseBody
	public String  statByNoMaintenanceMan9(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
		Ecemp obj = deviceParametersService.statByNoMaintenance9(zzjgdm);
		double bybhgsl = 0;
		double jdbhgsl = 0;
		double bnbhgsl = 0;
		double qnbhgsl = 0;
		if(obj.getBysl() != 0){
			bybhgsl = (obj.getBybhgsl()/obj.getBysl())*100;
			BigDecimal b  =  new  BigDecimal(bybhgsl);
			bybhgsl  =  b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
		}
		if(obj.getJdsl() != 0){
			jdbhgsl = (obj.getJdbhgsl()/obj.getJdsl())*100;
			BigDecimal b  =  new  BigDecimal(jdbhgsl);
			jdbhgsl  =  b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
		}
		if(obj.getBnsl() != 0){
			bnbhgsl = (obj.getBnbhgsl()/obj.getBnsl())*100;
			BigDecimal b  =  new  BigDecimal(bnbhgsl);
			bnbhgsl  =  b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
		}
		if(obj.getQnsl() != 0){
			qnbhgsl = (obj.getQnbhgsl()/obj.getQnsl())*100;
			BigDecimal b  =  new  BigDecimal(qnbhgsl);
			qnbhgsl  =  b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
		}
		Map params =  new HashMap();
		params.put("bysl", bybhgsl);
		params.put("jdsl", jdbhgsl);
		params.put("bnsl", bnbhgsl);
		params.put("qnsl", qnbhgsl);
		JSONArray array = JSONArray.fromObject(params);
		response.getWriter().print(array.toString());
		response.getWriter().flush();
		response.getWriter().close();
		return null;
	}

	//电梯故障情况统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenanceMan10"})
	@ResponseBody
	public List  statByNoMaintenanceMan10(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
		List<Ecemp> list = deviceParametersService.statByNoMaintenance10(zzjgdm);

		return list;
	}

	//电梯人员被困救援时间情况统计(首页统计)
	@RequiresPermissions("elmt:deviceParameters:index")
	@RequestMapping(value = {"statByNoMaintenanceMan11"})
	@ResponseBody
	public List  statByNoMaintenanceMan11(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
        String zzjgdm = UserUtils.getUser().getCompany().getCode();
		List<Ecemp> list = deviceParametersService.statByNoMaintenance11(zzjgdm);

		return list;
	}

    // 按日期显示每天维保电梯数，显示15天(首页统计)
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statEveryDayMainDevice"})
    @ResponseBody
    public List statEveryDayMainDevice(HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
        statParameters.put("wbdwdm", UserUtils.getUser().getCompany().getCode());
        statParameters.put("loginName", UserUtils.getUser().getLoginName());
        statParameters.put("dbName", Global.getConfig("jdbc.type"));
        List<HashMap> list = deviceParametersService.statEveryDayMainDevice(statParameters);
        return list;
    }

    // 按日期显示各个维保小组的维保数量
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statEveryDayMainDeviceGroup"})
    public String statEveryDayMainDeviceGroup(String oneday, HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
        statParameters.put("wbdwdm", UserUtils.getUser().getCompany().getCode());
        statParameters.put("dbName", Global.getConfig("jdbc.type"));
        statParameters.put("oneday", oneday);
        List<HashMap> list = deviceParametersService.statEveryDayMainDeviceGroup(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statMainGroupSb";
    }

    // 按日期显示各个维保小组的维保数量
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statEveryDayMainDeviceGroupList"})
    public String statEveryDayMainDeviceGroupList(String groupid, String oneday, HashMap statParameters, HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
        statParameters.put("wbdwdm", UserUtils.getUser().getCompany().getCode());
        statParameters.put("loginName", UserUtils.getUser().getLoginName());
        statParameters.put("dbName", Global.getConfig("jdbc.type"));
        statParameters.put("oneday", oneday);
        if ("0".equals(groupid)) {
            groupid = "zero";
        }
        statParameters.put("groupid", "1");
        List<DeviceParameters> list = deviceParametersService.statEveryDayMainDeviceGroupList(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statMainGroupSbList";
    }

    private HashMap getHashMap(String unitCode, String unitName, String unitAddress) {
        HashMap statParameters = new HashMap();
        statParameters.put("zzjqdm", unitCode);
        statParameters.put("dwmc", unitName);
        statParameters.put("dwdz", unitAddress);
        statParameters.put("wbdwdm", UserUtils.getUser().getCompany().getCode());
        statParameters.put("maintenUnitCode", UserUtils.getUser().getCompany().getCode());
        statParameters.put("dbName", Global.getConfig("jdbc.type"));
        return statParameters;
    }

    //电梯维保人员超额维保情况统计
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statByExcessMaintenance"})
    public String statByExcessMaintenance(String maintenancePersonnelName, String maintenanceUnitName, HttpServletRequest request, HttpServletResponse response, Model model) {
        HashMap statParameters = getHashMap(maintenancePersonnelName, maintenanceUnitName, "", "");
        List<HashMap> list = deviceParametersService.statByExcessMaintenance(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statByExcessMaintenance";
    }

    //电梯维保签到异常情况统计
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statBySignException"})
    public String statBySignException(String maintenancePersonnelName, String maintenanceUnitName, String maintenanceStartDate, String maintenanceEndDate, HttpServletRequest request, HttpServletResponse response, Model model) {
        HashMap statParameters = getHashMap(maintenancePersonnelName, maintenanceUnitName, maintenanceStartDate, maintenanceEndDate);
        List<HashMap> list = deviceParametersService.statBySignException(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statBySignException";
    }

    private HashMap getHashMap(String maintenancePersonnelName, String maintenanceUnitName, String maintenanceStartDate, String maintenanceEndDate) {
        HashMap statParameters = new HashMap();
        statParameters.put("staffName", maintenancePersonnelName);
        statParameters.put("maintenanceUnitName", maintenanceUnitName);
        if (StringUtils.isNotEmpty(maintenanceStartDate)) {
            statParameters.put("signInTime", maintenanceStartDate);
        }
        if (StringUtils.isNotEmpty(maintenanceEndDate)) {
            statParameters.put("completionTime", maintenanceEndDate);
        }
        statParameters.put("wbdwdm", UserUtils.getUser().getCompany().getCode());
        statParameters.put("maintenUnitCode", UserUtils.getUser().getCompany().getCode());
        statParameters.put("dbName", Global.getConfig("jdbc.type"));
        return statParameters;
    }

    private HashMap getHashMapParam(String maintenancePersonnelName, String maintenanceUnitName, String maintenanceStartDate, String maintenanceEndDate) {
        HashMap statParameters = new HashMap();
        statParameters.put("staffName", maintenancePersonnelName);
        statParameters.put("maintenanceUnitName", maintenanceUnitName);
        if (StringUtils.isNotEmpty(maintenanceStartDate)) {
            statParameters.put("reportTime", maintenanceStartDate);
        }
        if (StringUtils.isNotEmpty(maintenanceEndDate)) {
            statParameters.put("completionTime", maintenanceEndDate);
        }
        statParameters.put("wbdwdm", UserUtils.getUser().getCompany().getCode());
        statParameters.put("maintenUnitCode", UserUtils.getUser().getCompany().getCode());
        statParameters.put("dbName", Global.getConfig("jdbc.type"));
        return statParameters;
    }
    //电梯维保逾期情况统计
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statByMaintenanceOverdue"})
    public String statByMaintenanceOverdue(String maintenancePersonnelName, String maintenanceUnitName, String maintenanceStartDate, String maintenanceEndDate, HttpServletRequest request, HttpServletResponse response, Model model) {
        HashMap statParameters = getHashMap(maintenancePersonnelName, maintenanceUnitName, maintenanceStartDate, maintenanceEndDate);
        List<HashMap> list = deviceParametersService.statByMaintenanceOverdue(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statByMaintenanceOverdue";
    }

    //电梯维保不合格情况统计
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statByNoPassMaintenanceRecord"})
    public String statByNoPassMaintenanceRecord(String maintenancePersonnelName, String maintenanceUnitName, String maintenanceStartDate, String maintenanceEndDate, HttpServletRequest request, HttpServletResponse response, Model model) {
        HashMap statParameters = getHashMap(maintenancePersonnelName, maintenanceUnitName, maintenanceStartDate, maintenanceEndDate);
        List<HashMap> list = deviceParametersService.statByNoPassMaintenanceRecord(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statByNoPassMaintenanceRecord";
    }

    //电梯维保项目不合同情况统计
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statByNoPassMaintenanceItem"})
    public String statByNoPassMaintenanceItem(String maintenancePersonnelName, String maintenanceUnitName, String maintenanceStartDate, String maintenanceEndDate, HttpServletRequest request, HttpServletResponse response, Model model) {
        HashMap statParameters = getHashMap(maintenancePersonnelName, maintenanceUnitName, maintenanceStartDate, maintenanceEndDate);
        List<HashMap> list = deviceParametersService.statByNoPassMaintenanceItem(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statByNoPassMaintenanceItem";
    }

    //电梯故障报告情况统计
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statByFailureReport"})
    public String statByFailureReport(String maintenancePersonnelName, String maintenanceUnitName, String maintenanceStartDate, String maintenanceEndDate, HttpServletRequest request, HttpServletResponse response, Model model) {
        HashMap statParameters = getHashMapParam(maintenancePersonnelName, maintenanceUnitName, maintenanceStartDate, maintenanceEndDate);
        List<HashMap> list = deviceParametersService.statByFailureReport(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statByFailureReport";
    }

    //电梯困人情况统计
    @RequiresPermissions("elmt:deviceParameters:index")
    @RequestMapping(value = {"statByTrappedPeople"})
    public String statByTrappedPeople(String maintenancePersonnelName, String maintenanceUnitName, String maintenanceStartDate, String maintenanceEndDate, HttpServletRequest request, HttpServletResponse response, Model model) {
        HashMap statParameters = getHashMapParam(maintenancePersonnelName, maintenanceUnitName, maintenanceStartDate, maintenanceEndDate);
        List<HashMap> list = deviceParametersService.statByTrappedPeople(statParameters);
        model.addAttribute("list", list);
        return "zhuoyue/analysis/statByTrappedPeople";
    }

}